﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using Wpf.CommonTools.SystemExtension;

namespace Convertor.Plugin.GenerateSequence
{
    class TemplateTextRule : ValidationRule
    {
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
        {
            if (value == null || string.IsNullOrEmpty(value.ToString()))
            {
                return new ValidationResult(false, UILanguage.TryFindResource("Plugin_GenerateSequence_Result_TemplateTextEmptry"));
            }
            else if (!value.ToString().Contains("{0}"))
            {
                return new ValidationResult(false, UILanguage.TryFindResource("Plugin_GenerateSequence_Result_TemplateTextNotCorrect"));
            }
            else
            {
                return new ValidationResult(true, string.Empty);
            }
        }
    }
}
